{layout name="admin/layout" /}

<div class="col-xs-12">
    <div class="page-header">
        <h1>{:v('headtitle')}</h1>
    </div>
    <form class="form-inline" style="margin-bottom: 15px" action="{:url('Integral/index')}" method="get">
        <select class="form-control" name="type" style="width: 100px">
            <option value="1" {eq name="Think.get.type" value="1"}selected{/eq}>完成</option>
            <option value="0" {eq name="Think.get.type" value="0"}selected{/eq}>未完成</option>
        </select>
        <select class="form-control" name="key" style="width: 100px">
            <option value="bank_username" {eq name="Think.get.key" value="bank_username"}selected{/eq}>开户姓名</option>
            <option value="u_username" {eq name="Think.get.key" value="u_username"}selected{/eq}>用户手机</option>
        </select>
        <input type="text" name="value" class="input" value="{$Think.get.value}">
        <button class="btn btn-sm btn-success" type="submit">&nbsp;搜索&nbsp;</button>
    </form>
    <div class="table-responsive">
        <table id="sample-table-1" class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th class="center">
                        <label>
                            <input type="checkbox" class="ace"/>
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th>id</th>
                    <th>账户名称</th>
                    <th>提现金额</th>
                    <th>用户手机</th>
                    <th>银行卡/支付宝</th>
                    <th>开户/支付宝姓名</th>
                    <th>提现时间</th>
                    <th>积分类型</th>
                    <th>备注</th>
                    <th>提现状态</th>
                    <th>操作</th>
                </tr>
            </thead>

            <tbody>
            {volist name='list' id='v'}
                <tr>
                    <td class="center">
                        <label>
                            <input type="checkbox" class="ace"/>
                            <span class="lbl"></span>
                        </label>
                    </td>
                    <td>{$v.id}</td>
                    <td>{$v.u_nickname}</td>
                    <td>{$v.iu_integral}元</td>
                    <td>{$v.u_username}</td>
                    <td>{$v.bank_number}</td>
                    <td>{$v.bank_username}</td>
                    <td>{$v.createtime|date='Y-m-d H:i',###}</td>
                    <td>{eq name='v.iu_type' value='2'}套装积分{else /}领取积分{/eq}</td>
                    <td>
                        <button class="btn btn-xs btn-info message" data-url="{:url('Integral/msg',array('id'=>$v['id']))}" data-msg="{$v.msg}" data-id="{$v.id}">
                            {$v.msg}
                        </button>
                    </td>
                    <td>{eq name='v.state' value='1'}<span style="color: green;font-weight: bold">完成</span>{else /}<span style="color: red;font-weight: bold">未完成</span>{/eq}</td>
                    <td>
                        <div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                            {eq name='v.state' value='0'}
                            {if condition="has_menu($menu,'Integral/ok')"}
                            <button class="btn btn-xs btn-info ok" data-url="{:url('Integral/ok',array('id'=>$v['id']))}">
                                完成提现
                            </button>
                            {/if}
                            {/eq}
                        </div>
                    </td>
                </tr>
            {/volist}
            </tbody>
        </table>
    </div><!-- /.table-responsive -->
</div><!-- /span -->
{js href="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js" /}
{js href="__ROOT__/template/admin/assets/js/bootstrap.min.js" /}
{js href="__ROOT__/template/admin/assets/js/bootbox.min.js" /}
<script>
    $('.message').click(function () {
        var data_msg= $(this).attr('data-msg'),
            data_id = $(this).attr('data-id'),
            url     = $(this).attr('data-url'),
            content = '<input class="bootbox-input form-control msg" type="text" name="msg" value="' + data_msg + '">';
        bootbox.dialog({
            title: '友情提示：',
            message: content,
            buttons: {
                "success" : {
                    "label" : "确定",
                    "className" : "btn-success",
                    "callback": function() {
                        var msg = $('.msg').val();
                        $.get(url, {id:data_id,msg:msg}, function (ret) {
                            showMsg(ret.msg,ret.code);
                            setTimeout(function () {
                                window.location.reload();
                            },1000)
                        })
                    }
                },
                "close" : {
                    "label" : "取消",
                    "className" : "btn"
                }
            }
        });
    });

    $('.ok').click(function () {
        if(confirm('确定要提交完成提现吗？')) {
            var url = $(this).attr('data-url');
            $.get(url, function (ret) {
                showMsg(ret.msg, ret.code);
                if (ret.url) setTimeout(function () {
                    window.location.href = ret.url;
                }, 1000);
            });
        }
    })
</script>